<template>
   <el-card shadow="never">
       <el-form style="max-width:400px">
         <el-form-item label="次数">
            <el-input v-model="count"></el-input>
         </el-form-item>
         <el-form-item>
            <el-button @click="save" type="primary">保存</el-button>
         </el-form-item>
       </el-form>
    </el-card>
</template>
<script setup lang='ts'>
import userApi from "@/api/user";

const count = ref('')
const id=ref(0)
const save=()=>{
  userApi.updateCount({freeTimes:count.value,id:id.value}).then((res:any)=>{
    count.value=res.freeTimes
    id.value=res.id
  })
}
onMounted(()=>{
  userApi.getCount().then((res:any)=>{
      count.value=res
  })
})
</script>
<style lang='scss' scoped>
.box {
    padding: 40px 0 60px;
    margin: 0 auto;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.title {
    padding-top: 5rem;
    display: flex;
    flex-direction: column;
}

.el-row--flex.is-justify-center {
    justify-content: center;
}
</style>